package com.atjava.nebula.web.action;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.atjava.nebula.core.util.context.SpringContextHolder;
import com.atjava.nebula.web.security.NebulaAuthSuccessHandler;

@Controller
public class RootAction {

	@RequestMapping(value = "/") 
	public void redirect(HttpServletResponse response) throws IOException{
		
		NebulaAuthSuccessHandler sucsHandler = 
				(NebulaAuthSuccessHandler)SpringContextHolder.getBean("authSuccessHandler");
		
		String defaultUrl = sucsHandler.getDefaultUrl();
		if(defaultUrl.startsWith("/")){
			defaultUrl = defaultUrl.substring(1);
		}
		response.sendRedirect(defaultUrl);
	}
	
}
